package cn.demo.service0.controller;

import cn.demo.service0.entity.User;
import cn.demo.service0.mapper.TestMapper;
import cn.demo.service0.source.SimpleSourceBean;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import java.util.concurrent.TimeUnit;

/**
 * @Author: liujiahao
 * @Description:
 */
@RestController
@RefreshScope
//@EnableResourceServer//受保护的资源
public class Service0Controller {
    @Value("${server.name}")
    private String severName;
    @Autowired
    RestTemplate restTemplate;

    @Autowired
    TestMapper mapper;
    @Autowired
    private SimpleSourceBean simpleSourceBean;
    @GetMapping("pro")
    public String pro(){
        User user=new User();
        user.setId(1);
        user.setName("ljh");
        simpleSourceBean.publishOrgChandge(user);
        //System.out.println(mapper.findTest());
        return severName;
    }

    @GetMapping("pros")
    public String pros(){
        String data=restTemplate.getForObject("http://service1/test",String.class);
        return data;
    }
    public String error() {
        return "error";
    }

}
